package com.restaurant.application.score.support;

import com.google.common.collect.Lists;
import com.nebutown.generation.Convert;
import com.nebutown.generation.PickableBean;
import com.nebutown.generation.basictype.UID;

import java.util.List;

public class ScoreData implements PickableBean {
    
    public static final String FN_ID = "id";
    public static final String FN_SHOP = "shop";
    public static final String FN_SHOPID = "shopId";
    public static final String FN_SHOPNAME = "shopName";
    public static final String FN_PAYING = "paying";
    public static final String FN_SCORE = "score";
    public static final String FN_CREATETIME = "createTime";
    public static final String FN_MODIFYTIME = "modifyTime";

    public static final List<String> FIELD_NAMES = Lists.newArrayList(
            FN_ID,
            FN_SHOP,
            FN_SHOPID,
            FN_SHOPNAME,
            FN_PAYING,
            FN_SCORE,
            FN_CREATETIME,
            FN_MODIFYTIME);
    
    private String id;
    private UID shop;
    private String shopId;
    private String shopName;
    private Long paying;
    private Integer score;
    private Long createTime;
    private Long modifyTime;

    public ScoreData(String id, UID shop, String shopId, String shopName, Long paying, Integer score, Long createTime, Long modifyTime) {
        setId(id);
        setShop(shop);
        setShopId(shopId);
        setShopName(shopName);
        setPaying(paying);
        setScore(score);
        setCreateTime(createTime);
        setModifyTime(modifyTime);
    }

    public ScoreData() {
    }

    public ScoreData duplicate() {
        ScoreData result = new ScoreData();
        result.id = this.id;
        result.shop = this.shop;
        result.shopId = this.shopId;
        result.shopName = this.shopName;
        result.paying = this.paying;
        result.score = this.score;
        result.createTime = this.createTime;
        result.modifyTime = this.modifyTime;
        return result;
    }

    @Override
    public String toString() {
        return Convert.toJson(this);
    }

    public String getId() {
        return id;
    }

    public void setId(String value) {
        this.id = value;
    }

    public ScoreData withId(String value) {
        setId(value);
        return this;
    }

    public ScoreData withId(String value, String defaultValue) {
        setId(value == null ? defaultValue : value);
        return this;
    }

    public UID getShop() {
        return shop;
    }

    public void setShop(UID value) {
        this.shop = value;
    }

    public ScoreData withShop(UID value) {
        setShop(value);
        return this;
    }

    public ScoreData withShop(UID value, UID defaultValue) {
        setShop(value == null ? defaultValue : value);
        return this;
    }

    public String getShopId() {
        return shopId;
    }

    public void setShopId(String value) {
        this.shopId = value;
    }

    public ScoreData withShopId(String value) {
        setShopId(value);
        return this;
    }

    public ScoreData withShopId(String value, String defaultValue) {
        setShopId(value == null ? defaultValue : value);
        return this;
    }

    public String getShopName() {
        return shopName;
    }

    public void setShopName(String value) {
        this.shopName = value;
    }

    public ScoreData withShopName(String value) {
        setShopName(value);
        return this;
    }

    public ScoreData withShopName(String value, String defaultValue) {
        setShopName(value == null ? defaultValue : value);
        return this;
    }

    public Long getPaying() {
        return paying;
    }

    public void setPaying(Long value) {
        this.paying = value;
    }

    public ScoreData withPaying(Long value) {
        setPaying(value);
        return this;
    }

    public ScoreData withPaying(Long value, Long defaultValue) {
        setPaying(value == null ? defaultValue : value);
        return this;
    }

    public Integer getScore() {
        return score;
    }

    public void setScore(Integer value) {
        this.score = value;
    }

    public ScoreData withScore(Integer value) {
        setScore(value);
        return this;
    }

    public ScoreData withScore(Integer value, Integer defaultValue) {
        setScore(value == null ? defaultValue : value);
        return this;
    }

    public Long getCreateTime() {
        return createTime;
    }

    public void setCreateTime(Long value) {
        this.createTime = value;
    }

    public ScoreData withCreateTime(Long value) {
        setCreateTime(value);
        return this;
    }

    public ScoreData withCreateTime(Long value, Long defaultValue) {
        setCreateTime(value == null ? defaultValue : value);
        return this;
    }

    public Long getModifyTime() {
        return modifyTime;
    }

    public void setModifyTime(Long value) {
        this.modifyTime = value;
    }

    public ScoreData withModifyTime(Long value) {
        setModifyTime(value);
        return this;
    }

    public ScoreData withModifyTime(Long value, Long defaultValue) {
        setModifyTime(value == null ? defaultValue : value);
        return this;
    }

    public Object getValueOf(String name) {
        switch (name) {
            case "id":
                return getId();
            case "shop":
                return getShop();
            case "shopId":
                return getShopId();
            case "shopName":
                return getShopName();
            case "paying":
                return getPaying();
            case "score":
                return getScore();
            case "createTime":
                return getCreateTime();
            case "modifyTime":
                return getModifyTime();
        }
        return null;
    }

    public boolean hasField(String name) {
        return FIELD_NAMES.contains(name);
    }

    @Override
    public int hashCode() {
        return signature().hashCode();
    }

    @Override
    public boolean equals(Object o) {
        if (!(o instanceof ScoreData)) return false;
        return signature().equals(((ScoreData) o).signature());
    }

    public String signature() {
        throw new RuntimeException("Bean ScoreData has no signature defined, no hash code or equals possible.");
    }
}
